Skip to content

Commit 7281bbc

Browse files
authored
Merge pull request #6660 from escattone/add-spam-confidence-2326
add spam confidence
2 parents 6dd0f4b + 52cd90c commit 7281bbc

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

kitsune/llm/questions/prompt.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
- It contains QR codes or images containing external links.
2424
- It is not relevant to Mozilla's "{product}" product.
2525
26-
# Specific instructions
26+
# Instructions
2727
Given a question, you must do the following:
2828
- Determine whether or not the question is spam by considering each of the spam cases
2929
listed above.
3030
- Provide a reason for your determination.
31+
- Provide your level of confidence in the determination as an integer from 0 to 100, with
32+
0 representing the lowest confidence and 100 the highest.
3133
3234
# Response format instructions
3335
{format_instructions}
@@ -48,9 +50,10 @@
4850
{topics}
4951
```
5052
51-
# Specific instructions
52-
- Given a question, consider the title, description, and examples of each one of the
53-
eligible topics listed above, and then select the most relevant topic.
53+
# Instructions
54+
Given a question, you must do the following:
55+
- Consider the title, description, and examples (if provided) of each one of the eligible
56+
topics listed above, and then select the most relevant topic.
5457
- If you conclude that the question does not relate to Mozilla's "{product}" product,
5558
or does not provide enough information to make a selection, select the "Undefined" topic.
5659
- Provide a reason for your selection.
@@ -67,9 +70,18 @@
6770
type="bool",
6871
description="A boolean that when true indicates that the question is spam.",
6972
),
73+
ResponseSchema(
74+
name="confidence",
75+
type="int",
76+
description=(
77+
"An integer from 0 to 100 that indicates the level of confidence in the"
78+
" determination of whether or not the question is spam, with 0 representing"
79+
" the lowest confidence and 100 the highest."
80+
),
81+
),
7082
ResponseSchema(
7183
name="reason",
72-
type="string",
84+
type="str",
7385
description="The reason for identifying the question as spam or not spam.",
7486
),
7587
)
@@ -80,19 +92,29 @@
8092
(
8193
ResponseSchema(
8294
name="topic",
83-
type="string",
84-
description="The topic selected for the question.",
95+
type="str",
96+
description="The title of the topic selected for the question.",
8597
),
8698
ResponseSchema(
8799
name="reason",
88-
type="string",
100+
type="str",
89101
description="The reason for selecting the topic.",
90102
),
91103
)
92104
)
93105

94106

95-
spam_prompt = ChatPromptTemplate((("system", SPAM_INSTRUCTIONS), ("human", "{question}")))
107+
spam_prompt = ChatPromptTemplate(
108+
(
109+
("system", SPAM_INSTRUCTIONS),
110+
("human", "{question}"),
111+
)
112+
).partial(format_instructions=spam_parser.get_format_instructions())
96113

97114

98-
topic_prompt = ChatPromptTemplate((("system", TOPIC_INSTRUCTIONS), ("human", "{question}")))
115+
topic_prompt = ChatPromptTemplate(
116+
(
117+
("system", TOPIC_INSTRUCTIONS),
118+
("human", "{question}"),
119+
)
120+
).partial(format_instructions=topic_parser.get_format_instructions())

0 commit comments

Comments
 (0)